package com.zxl.grocerymicroservicewechatmeal.utils;

import com.zxl.grocerymicroservicewechatmeal.enums.CodeEnum;

/**
 * @Author: zxl
 * @Description: 传入一个Integer类型的code 返回对应的枚举值
 * @Date: Created in 9:18 2017/11/16
 * @Modified By:
 */
public class EnumUtil {
    public static <T extends CodeEnum> T getByCode(Integer code, Class<T> enumClass) {
        for (T each: enumClass.getEnumConstants()) {
            if (code.equals(each.getCode())) {
                return each;
            }
        }
        return null;
    }
}
